package Adapter

import "fmt"

type IPlug interface {
	GetValidVoltage() float32
}

type ChinesePlug struct {
	IPlug
}
type AmericanPlug struct {
	IPlug
}

func (plug *ChinesePlug) GetValidVoltage() float32 {
	return 220
}
func (plug *AmericanPlug) GetValidVoltage() float32 {
	return 110
}

func (plug *ChinesePlug) UseChineseSocket(socket ISocket) {
	if plug.GetValidVoltage() == socket.GetVoltage() {
		fmt.Printf("电压输入匹配，国产插头工作正常，电压：%f\n", plug.GetValidVoltage())
	} else {
		fmt.Printf("电压输入不匹配，国产插头无法工作，期望输入电压：%f，实际输入：%f\n", plug.GetValidVoltage(), socket.GetVoltage())
	}
}

func (plug *AmericanPlug) UseAmericanSocket(socket ISocket) {
	if plug.GetValidVoltage() == socket.GetVoltage() {
		fmt.Printf("电压输入匹配，美标插头工作正常，电压：%f\n", plug.GetValidVoltage())
	} else {
		fmt.Printf("电压输入不匹配，美标插头无法工作，期望输入电压：%f，实际输入：%f\n", plug.GetValidVoltage(), socket.GetVoltage())
	}
}
